//
//  SQMessageTableViewCell.m
//  SQ_NEW
//
//  Created by 刘明 on 2017/5/13.
//  Copyright © 2017年 刘明. All rights reserved.
//

#import "SQMessageTableViewCell.h"


@implementation SQMessageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.iconImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.width.height.mas_equalTo(40);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
        
    }];
    
    
    self.iconImageView = [[UIImageView alloc] init];
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.cornerRadius = 20;
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.height.mas_equalTo(40);
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(10);
    }];
    
    
    self.redCountLabel = [[UILabel alloc] init];
    self.redCountLabel.layer.masksToBounds = YES;
    self.redCountLabel.layer.cornerRadius = 10;
    self.redCountLabel.backgroundColor = LMRedColor;
    self.redCountLabel.textColor = LMWhiteColor;
    self.redCountLabel.textAlignment = NSTextAlignmentCenter;
    self.redCountLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.redCountLabel];
    [self.redCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.height.mas_equalTo(20);
        make.left.equalTo(self.iconImageView.mas_right).with.offset(-5);
        make.top.equalTo(self.iconImageView.mas_top).with.offset(-5);
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.textColor = S_Color_51;
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(0);
        make.left.equalTo(self.iconImageView.mas_right).with.offset(10);
    }];
    
    
    self.timeLabel = [[UILabel alloc] init];
    self.timeLabel.textColor = S_Color_51;
    self.timeLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-10);
    }];
    

 

    
    
}


- (void)setSocketModel:(SQSocketSysModel *)socketModel{
    
    _socketModel = socketModel;
    
    NSString *title_str = self.socketModel.title;
    if ([title_str isEqualToString:@"xtxx"]) {
        self.iconImageView.image = [UIImage imageNamed:@"Noticethree_notice.png"];
        self.titleLabel.text = @"系统消息";
    }else if ([title_str isEqualToString:@"xmtg"]){
        self.iconImageView.image = [UIImage imageNamed:@"Noticethree_ground.png"];
        self.titleLabel.text = @"项目推广";
    }else if ([title_str isEqualToString:@"xmcy"]){
        self.iconImageView.image = [UIImage imageNamed:@"Noticethree_join.png"];
        self.titleLabel.text = @"项目参与";
    }else if ([title_str isEqualToString:@"sqtz"]){
        self.iconImageView.image = [UIImage imageNamed:@"Noticethree_apply.png"];
        self.titleLabel.text = @"申请与验证";
    }else if ([title_str isEqualToString:@"jftz"]){
        self.iconImageView.image = [UIImage imageNamed:@"Noticethree_money.png"];
        self.titleLabel.text = @"缴费通知";
    }
    
    self.timeLabel.text = self.socketModel.time;
    
    if ( [self.socketModel.unReadMsgCount intValue] == 0) {
        self.redCountLabel.hidden = YES;
    }else{
        self.redCountLabel.hidden = NO;
        self.redCountLabel.text = self.socketModel.unReadMsgCount;
        
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
